package com.zeny.xdclass.config;

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

/**
 * @ClassName WeChatConfig
 * @Description 微信配置类
 * @Author zeny
 */
@Configuration
@PropertySource(value = "classpath:application.yml")
@Data
public class WeChatConfig {

    /**
     * @Description 商户号Id
     **/
    @Value("${wxpay.payAppid}")
    private String payAppid;

    /**
     * @Description 商户号Id
     **/
    @Value("${wxpay.mer_id}")
    private String merId;

    /**
     * @Description 支付key
     **/
    @Value("${wxpay.key}")
    private String key;

    /**
     * @Description 支付回调地址
     **/
    @Value("${wxpay.callback}")
    private String payCallbackUrl;

    /**
     * @Description 公众号appid
     **/
    @Value("${wxpay.appid}")
    private String appid;

    /**
     * @Description 公众号秘钥
     **/
    @Value("${wxpay.appsecret}")
    private String appsecret;

    /**
     * @Description 微信开放平台appid
     **/
    @Value("${wxopen.appid}")
    private String wxopenAppid;

    /**
     * @Description 微信开放平台秘钥
     **/
    @Value("${wxopen.appsecret}")
    private String wxopenAppsecret;

    /**
     * @Description 微信开放平台回调地址
     **/
    @Value("${wxopen.redirect_url}")
    private String wxopenRedirectUurl;

    /**
     * @Description 微信开放平台获取access_token地址
     **/
    private final static String OPEN_ACCESS_TOKEN_RUL = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code";

    /**
     * @Description 获取用户信息
     */
    private final static String OPEN_USER_INFO_URL ="https://api.weixin.qq.com/sns/userinfo?access_token=%s&openid=%s&lang=zh_CN";

    /**
     * @Description 微信开放平台二维码连接
     **/
    private static final String OPEN_QRCODE_URL = "https://open.weixin.qq.com/connect/qrconnect?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_login&state=%s#wechat_redirect";

    /**
     * 统一下单url
     */
    private static final String UNIFIED_ORDER_URL = "https://api.mch.weixin.qq.com/pay/unifiedorder";


    public String getOpenQrcodeUrl() {
        return OPEN_QRCODE_URL;
    }

    public String getOpenAccessTokenRul() {
        return OPEN_ACCESS_TOKEN_RUL;
    }

    public String getOpenUserInfoUrl() {
        return OPEN_USER_INFO_URL;
    }

    public String getUnifiedOrderUrl() {
        return UNIFIED_ORDER_URL;
    }
}
